package com.ruoyi.system.service.impl;

import java.io.File;
import java.util.List;
import java.util.UUID;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.file.ImageFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysRecordMapper;
import com.ruoyi.system.domain.SysRecord;
import com.ruoyi.system.service.ISysRecordService;

/**
 * 采集记录表Service业务层处理
 * 
 * @author fhs
 * @date 2020-12-11
 */
@Service
public class SysRecordServiceImpl implements ISysRecordService 
{
    @Autowired
    private SysRecordMapper sysRecordMapper;

    /**
     * 查询采集记录表
     * 
     * @param id 采集记录表ID
     * @return 采集记录表
     */
    @Override
    public SysRecord selectSysRecordById(String id)
    {
        return sysRecordMapper.selectSysRecordById(id);
    }

    /**
     * 查询采集记录表列表
     * 
     * @param sysRecord 采集记录表
     * @return 采集记录表
     */
    @Override
    public List<SysRecord> selectSysRecordList(SysRecord sysRecord)
    {
        return sysRecordMapper.selectSysRecordList(sysRecord);
    }

    /**
     * 新增采集记录表
     * 
     * @param sysRecord 采集记录表
     * @return 结果
     */
    @Override
    public int insertSysRecord(SysRecord sysRecord)
    {
        sysRecord.setId(UUID.randomUUID().toString());
        return sysRecordMapper.insertSysRecord(sysRecord);
    }

    @Override
    public int insertSysRecordfromeDev(SysRecord sysRecord)
    {
        sysRecord.setId(UUID.randomUUID().toString());
        String idcardimg = sysRecord.getIdcardimg();
        if(null!=idcardimg&&!idcardimg.equals("")){
            ImageFactory.GenerateImage(idcardimg, sysRecord.getId() + "_idcard.jpg");
            sysRecord.setIdcardimg( "/dev-api/"+Constants.RESOURCE_PREFIX+Constants.RESOURCE_PREFIX1+"/"+DateUtils.datePath()+ sysRecord.getId() + "_idcard.jpg");
        }

        String personimg = sysRecord.getPersonimg();
        if(null!=personimg&&!personimg.equals("")){
            ImageFactory.GenerateImage(personimg, sysRecord.getId() + "_person.jpg");
            sysRecord.setPersonimg( "/dev-api/"+Constants.RESOURCE_PREFIX+Constants.RESOURCE_PREFIX1+"/"+DateUtils.datePath()+ sysRecord.getId() + "_person.jpg");
        }
        return sysRecordMapper.insertSysRecord(sysRecord);
    }
    /**
     * 修改采集记录表
     * 
     * @param sysRecord 采集记录表
     * @return 结果
     */
    @Override
    public int updateSysRecord(SysRecord sysRecord)
    {
        return sysRecordMapper.updateSysRecord(sysRecord);
    }

    /**
     * 批量删除采集记录表
     * 
     * @param ids 需要删除的采集记录表ID
     * @return 结果
     */
    @Override
    public int deleteSysRecordByIds(String[] ids)
    {
        return sysRecordMapper.deleteSysRecordByIds(ids);
    }

    /**
     * 删除采集记录表信息
     * 
     * @param id 采集记录表ID
     * @return 结果
     */
    @Override
    public int deleteSysRecordById(String id)
    {
        return sysRecordMapper.deleteSysRecordById(id);
    }
}
